Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(*): utilize rxjs(5.5 and above) lettable operators #35

Merged
merged 1 commit into from
Jan 27, 2018

Conversation

chuan6
Copy link
Contributor

@chuan6 chuan6 commented Jan 1, 2018

目的:

  • 更清晰地表达一些读入流、输出流的操作,并帮助进一步提取其中的纯函数;
  • 通过 pipe 方法组合纯函数,令流管理更像搭积木;
  • 令每个模块各自对 rxjs 操作符的依赖更清晰。

@chuan6 chuan6 self-assigned this Jan 1, 2018
@coveralls
Copy link

coveralls commented Jan 1, 2018

Coverage Status

Coverage increased (+0.03%) to 96.576% when pulling 6d1da59 on chore/rxjs-pipe-lettables into 767f329 on master.

import { debounceTime } from 'rxjs/operators/debounceTime'
import { map } from 'rxjs/operators/map'
import { mergeMap } from 'rxjs/operators/mergeMap'
import { publishReplay } from 'rxjs/operators/publishReplay'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

publishReplay(1).refCount() 好像可以被换成 shareReplay(1)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Brooooooklyn shareReplay 的区别是出错了之后可以 retry,继续广播接下来可能成功生成的值是吗?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shareReplay 只是 publishReplay + refCount 的语法糖

Copy link
Contributor Author

@chuan6 chuan6 Jan 22, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Brooooooklyn ReactiveX/rxjs#453 ,好几遍都没看下来@~@

好像是最终 benlesh 接受了 stalz 和 mattpodwysocki 要 fork rxjs 的威胁,放弃对 ReplaySubject 语义的调整,另找办法,不通过 multicast + replaysubject 的办法,而是直接手写一个支持广播及回放功能,又支持 retry 的操作符(可能后来就成了新版的 shareReplay,里面手动使用 ReplaySubject 而不用 multicast)。

不过这两者的确是有不同的,publishReplay(1).refCount() 不能 retry,shareReplay(1) 可以。

看样子是用 shareReplay 比较好了 :)

@chuan6
Copy link
Contributor Author

chuan6 commented Jan 2, 2018

@Brooooooklyn 谢谢!这个我代码才大致改好,想再看看对打包的影响(或者有什么需要调整优化的地方)。代码修改上,你觉得大致可以吗?使用 pipe 的例子我看得并不多,所以不确定对不对。

@Brooooooklyn
Copy link
Member

resolve conflict

目的:

 - 更清晰地表达一些读入流、输出流的操作,并帮助进一步提取其中的纯函数;
 - 通过 pipe 方法组合纯函数,令流管理更像搭积木;
 - 令每个模块各自对 rxjs 操作符的依赖更清晰。
@chuan6
Copy link
Contributor Author

chuan6 commented Jan 26, 2018

@Brooooooklyn resolve 掉了,谢谢 🙏

@Brooooooklyn Brooooooklyn merged commit 1ebf0bd into master Jan 27, 2018
@Brooooooklyn Brooooooklyn deleted the chore/rxjs-pipe-lettables branch January 27, 2018 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants